<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .container {
            width: 100%;
            max-width: 360px;
            padding: 20px;
            background-color: white;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
            text-align: center;
        }
        h2 {
            color: #333;
            margin-bottom: 20px;
        }
        form {
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        label {
            display: block;
            width: 100%;
            text-align: left;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ccc;
            border-radius: 4px;
            font-size: 14px;
        }
        input[type="submit"] {
            width: 100%;
            padding: 10px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
        }
        input[type="submit"]:hover {
            background-color: #45a049;
        }
        .links {
            margin-top: 15px;
            font-size: 12px;
        }
        .links a {
            color: #4CAF50;
            text-decoration: none;
        }
        .links a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>用户登录</h2>
        <form id="loginForm">
            <label for="username">用户名</label>
            <input type="text" id="username" name="username" placeholder="请输入用户名" required>

            <label for="password">密码</label>
            <input type="password" id="password" name="password" placeholder="请输入密码" required>

            <input type="submit" value="登录">
        </form>
        <div class="links">
            <a href="#">忘记密码？</a><br>
            <a href="#">注册新账号</a>
        </div>
    </div>
    <script>
        document.getElementById("loginForm").addEventListener("submit", function(event) {
            event.preventDefault(); // 阻止表单默认提交行为

            const username = document.getElementById("username").value;
            const password = document.getElementById("password").value;

            // 简单的验证逻辑（实际开发中应通过后端验证）
            if (username === "" || password === "") {
                alert("用户名和密码不能为空！");
                return;
            }

            // 模拟登录成功
            alert("登录成功！欢迎，" + username + "！");
            // 这里可以添加代码将数据发送到服务器进行验证
        });
    </script>
</body>
</html>